const Actions = require('./actions');
const DB = require('app/db.js');
import { Storage } from 'clientConfig/util/StoreData'
import { Toast } from 'saltui';
module.exports = Reflux.createStore({
    listenables: [Actions],
    data: {
        title: ''
    },
    onFetch: function (params,cb) {
        let t = this;
        DB.Parent.get_generalClass_list({
            schoolId: Storage.get('user.schoolId'),
            studentId: Storage.get('user.studentId'),
        })
            .then((content) => {
                if (content.code == 1) {
                    if (content && content.data) {
                        content = content.data;
                        Object.assign(t.data,content);
                        t.updateComponent();
                    }
                }else{
                    Toast.show({
                        type: 'error',
                        content: '系统异常'
                    });
                }
            })
            .catch(function (error) {
                Toast.show({
                    type: 'error',
                    content: '系统异常'
                });
            });
    },
    updateComponent: function () {
        this.trigger(this.data);
    }
});
